﻿using System;
using System.Collections.Generic;
using System.Web;

/// <summary>
/// Summary description for DateUtil
/// </summary>
public class DateUtil
{   
   
	public DateUtil()
	{
        
		//
		// TODO: Add constructor logic here
		//
	}
    /// <summary>
    /// Convert String to Date
    /// Example :
    ///     Input : 24/01/2013
    ///     Output : 01/24/2013 02:15:12
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static string convertStringToDate(string dateInsert)
    {
        string[] date = dateInsert.Trim().Split('/');

        DateTime dt = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0]), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
        string d = String.Format("{0:MM/dd/yyyy HH:mm:ss}", dt);
        return d;
    }

    /// <summary>
    /// Convert String to Date
    /// Example :
    ///     Input : 24/01/2013
    ///     Output : 01/24/2013 02:15:12
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static DateTime convertStringToDate2(string dateInsert)
    {
        string[] date = dateInsert.Trim().Split('/');

        DateTime dt = new DateTime(int.Parse(date[2]), int.Parse(date[1]), int.Parse(date[0]), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
        return dt;
    }

    /// <summary>
    /// Convert String to Date
    /// Example :
    ///     Input : 01/24/2013 02:15:12
    ///     Output : 24/01/2013 02:15:12
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static string convertDateToString(DateTime dt)
    {
        return String.Format("{0:MM/dd/yyyy HH:mm:ss}", dt);
    }

    /// <summary>
    /// Convert String to Date
    /// Example :
    ///     Input : 01/24/2013 02:15:12
    ///     Output : 24/01/2013
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public static string convertDateToString2(DateTime dt)
    {
        return String.Format("{0:MM/dd/yyyy}", dt);
    }
    /// <summary>
    /// Calendar Month substract get date
    /// Exmpale
    ///     Input : 3  get date 01/2013
    ///     Output : 01/2013 , 12/2013, 11/2013
    /// </summary>
    /// <param name="size"></param>
    /// <returns></returns>
    public static DateTime[] calendarMonth(int size)
    {
        DateTime[] dt = new DateTime[size];
        int count = 0;
        for (int i = 0; i < size; i++)
        {
            dt[i] = DateTime.Now.AddMonths(count--);

        }
        return dt;
    }
   
}